<?php
namespace  app\http\Service\Agent;

use App\Http\Service\Basic\BasicService;
use Config;

class AgentService extends BasicService
{
    //构造函数
    function __construct(){
        parent::__construct();
    }

    /**
     * @return bool|mixed
     * 代理汇总
     */
    public function Agent($where)
    {
        $url=self::Where($where);

        return  $this->curlLogic->callWebServer(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.agent').$url);

    }

    /**
     * @param $where
     * @return bool|mixed
     * 一级用户
     */
    public function Level_one($where)
    {
        $url=self::Where($where);
//        dd(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.level').$url);
        return  $this->curlLogic->callWebServer(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.level').$url);

    }

    /**
     * @param $where
     * @return bool|mixed
     * 二级用户
     */
    public function Level_two($where)
    {
        $url=self::Where($where);

        return  $this->curlLogic->callWebServer(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.level').$url);

    }

    /**
     * @param $where
     * @return bool|mixed
     *三级用户
     */
    public function Level_three($where)
    {
        $url=self::Where($where);

        return  $this->curlLogic->callWebServer(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.level').$url);

    }

    /**
     * @param $where
     * @return bool|mixed
     * 其他用户
     */

    public function Other($where)
    {
        $url=self::Where($where);

        return  $this->curlLogic->callWebServer(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.level').$url);

    }

    /**
     * @param $where
     * @return bool|mixed
     * 搜索
     */
    public function Search($where)
    {
        $url=self::Where($where);
        return  $this->curlLogic->callWebServer(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.level').$url);

    }

    public function detail($where)
    {
        $url=self::Where($where);
//        dd(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.detail').$url);
        return  $this->curlLogic->callWebServer(Config::get('custom.setting.BASE_API_PATH').Config::get('custom.api.detail').$url);

    }

    /**
     * @param $where
     * @return string
     * 条件
     */
    public function Where($where)
    {
        $url = '';
        if(isset($where['token'])){
            $url .='&token='.$where['token'];
        }
        if(isset($where['level'])){
            $url .='&level='.$where['level'];
        }
        if(isset($where['page_no'])){
            $url .='&page_no='.$where['page_no'];
        }
        if(isset($where['start_date'])){
            $url .='&start_date='.$where['start_date'];
        }
        if(isset($where['end_date'])){
            $url .='&end_date='.$where['end_date'];
        }
        if(isset($where['space'])){
            $url .='&space='.$where['space'];
        }
        if(isset($where['user_id'])){
            $url .='&user_id='.$where['user_id'];
        }
        return $url;
    }





}







